package main

func main() {

}

func majorityElement(nums []int) int {
	l := len(nums)

	var cnt, base int
	for i := 0; i < l; i++ {
		if cnt == 0 {
			base = nums[i]
			cnt = 1
			continue
		}

		if nums[i] == base {
			cnt++
		} else {
			cnt--
		}
	}
	return base
}
